package com.konne.nightmare.FastPublicOpinion.ui.dialog;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.ui.information.activity.MoveClassActivity;
import com.konne.nightmare.FastPublicOpinion.utils.TipsUtils;
import com.konne.nightmare.FastPublicOpinion.widget.TriangleView;

/**
 * @Author: chen
 * @UpdateDate: 1/27/22
 * @UpdateRemark:
 */
public class ClassOnePopupWindow extends PopupWindow {
    private static final String TAG = "ClassOnePopupWindow";
    private Context context;
    private View popView;

    private TriangleView triangleView;
    private LinearLayout llEdit;
    private LinearLayout llDelete;

    public ClassOnePopupWindow(Context context) {
        this.context = context;
        popView = LayoutInflater.from(context).inflate(R.layout.pop_class_one_layout, null, false);
        setContentView(popView);
        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        setBackgroundDrawable(new ColorDrawable());
        setOutsideTouchable(true);//点击外部消失
        setTouchable(true); //设置可以点击
        triangleView = (TriangleView) popView.findViewById(R.id.triangleView);
        llEdit = (LinearLayout) popView.findViewById(R.id.ll_edit);
        llDelete = (LinearLayout) popView.findViewById(R.id.ll_delete);


        triangleView.setTriangleColor(ContextCompat.getColor(context,R.color.white));
        TipsUtils.setBackgroundAlpha((AppCompatActivity) context, 0.6f);

        setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                TipsUtils.setBackgroundAlpha((AppCompatActivity) context, 1.0f);
            }
        });
        llEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        llDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();

            }
        });

    }


}
